package com.study5.mybatis.dayima.service.impl;

import com.study5.mybatis.dayima.model.CarrierCode;
import com.study5.mybatis.dayima.service.CarrierCodeService;
import com.yoloho.cache.annotation.EnableCache;
import com.yoloho.cache.annotation.EnableCacheBoolean;
import com.yoloho.cache.annotation.EnableCacheConfig;
import com.yoloho.dao.api.EnhancedDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author xuly
 * @title: CarrierCodeServiceImpl
 * @projectName spring-boot
 * @description: TODO
 * @date 2019-07-2411:35
 **/
@Service("carrierCodeService")
@EnableCacheConfig(group = "CarrierCodeServiceImpl", expireLocal = 30, maxSizeLocal = 5000)
@Slf4j
public class CarrierCodeServiceImpl implements CarrierCodeService {

    @Resource
    private EnhancedDao<CarrierCode,Integer> carrierCodeEnhancedDao;

    @Override
    @EnableCache(key = "'getById' + #id", local = EnableCacheBoolean.ENABLE,remote = EnableCacheBoolean.ENABLE,expire = 600, expireLocal = 60)
    public CarrierCode getById(Integer id) {
        log.info("111");
        return carrierCodeEnhancedDao.get(id);
    }

    @Override
    @EnableCache(key = "'get' + #id", local = EnableCacheBoolean.ENABLE,remote = EnableCacheBoolean.ENABLE,expire = 600, expireLocal = 60)
    public Boolean get(Integer id) {
        log.info("111");
        return carrierCodeEnhancedDao.get(id) == null;
    }

}
